package com.soft.service;

import com.soft.dao.LeaveEmpDaoImpl;
import com.soft.pojo.Left;
import com.soft.utils.Result;

import java.util.ArrayList;

/**
 * @author ruoxi
 * @create 2021-12-27 10:34
 */
public class LeaveEmpService {
    private LeaveEmpDaoImpl leaveEmpDao = new LeaveEmpDaoImpl();

    public int findLeaveEmpCount() {
        return leaveEmpDao.selectByAll().size();
    }

    public ArrayList<Left> findLeaveEmpByPage(int currentPage, int currentCount) {
        return (ArrayList<Left>) leaveEmpDao.selectLeaveEmpByPage(currentPage, currentCount);
    }

    public Left findLeaveEmpById(int id) {
        return leaveEmpDao.selectLeaveEmpById(id);
    }

    public Result leaveCheckPass(int eno){
        int line = leaveEmpDao.leaveCheckPass(eno);
        if (line>1){
            return Result.me().setMsg("已通过");
        }
        return Result.me(false).setMsg("系统问题,通过失败");
    }

    public  Result leaveCheckFail(int eno){
        int line = leaveEmpDao.leaveCheckFail(eno);
        if (line>0){
            return Result.me().setMsg("已拒绝");
        }
        return Result.me(false).setMsg("系统问题,拒绝失败");
    }
}
